/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pbl_cliente;

import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Asuka
 */
public class RecebedorPing implements Runnable{
    private InputStream clientein;
    private String dadoPing;
    private OutputStream clienteout;
    private PBL_cliente pbl_cli;
    
    public RecebedorPing(InputStream in, OutputStream out, PBL_cliente pc){
        this.clientein = in;
        this.clienteout = out;
        this.pbl_cli = pc;
    }
    @Override
    public void run(){
        while(true){
        try {
            DataInputStream ler = new DataInputStream(clientein);
            //wait(5000);
            dadoPing = ler.readUTF();
            pbl_cli.TrataMsgsVindasServidor(dadoPing);
//            TrataPingCliente tpc = new TrataPingCliente(clienteout,dadoPing);
//            new Thread(tpc).start();
//            if(dadoPing.split(":")[0].equals("PING")){
//                DataOutputStream esc = new DataOutputStream(clienteout);
//                esc.writeUTF("PING:OK:");
//            }
        }  catch (IOException ex) {
            Logger.getLogger(RecebedorPing.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }
    }
}

